package com.example.demo.entity;

import lombok.Data;

@Data
public class ResultModel {

    private String msg = "";
    private Integer code;
    private Object data;
    private long total = 0;

    public static ResultModel ok(Object data){
        ResultModel res = new ResultModel();
        res.setCode(200);
        res.setMsg("操作成功");
        res.setData(data);
        return res;
    }
    public static ResultModel ok(Object data,long total){
        ResultModel res = new ResultModel();
        res.setCode(200);
        res.setMsg("操作成功");
        res.setData(data);
        res.setTotal(total);
        return res;
    }

    public static ResultModel ok(String msg){
        ResultModel res = new ResultModel();
        res.setCode(200);
        res.setMsg(msg);
        return res;
    }
    public static ResultModel error(String msg){
        ResultModel res = new ResultModel();
        res.setCode(500);
        res.setMsg(msg);
        return res;
    }
}
